package com.example.administrator.androidhomework2;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;

/**
 * Created by Administrator on 2019/3/12.
 */

public class MyDialog  extends Dialog{
    Button mBtbOK,mbtnCancel;
    Context mContext;
    public MyDialog(@NonNull Context context){
        super(context);
        mContext = context;

    }
    @Override
    protected  void onCreate(Bundle saveInstanceState){
        super.onCreate(saveInstanceState);
        //将对话框的界面设置为对应的布局
        setContentView(R.layout.my_dialog_layout);
        mBtbOK = findViewById(R.id.btn_ok);
        mbtnCancel = findViewById(R.id.btn_cancel);

        mBtbOK.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //点击确定按钮执行的代码
                ((MainActivity)mContext).setmTvResult("as;adsasd;asdasd");
                MyDialog.this.dismiss();
            }
        });

    }
}
